package repo

import (
	"context"
	"github.com/go-kratos/kratos/v2/log"
	"go-kratos-demo/internal/dao"
	"go-kratos-demo/internal/data"
)

type geeterCache struct {
	data *data.Data
	log  *log.Helper
}

// NewGeeterCache .
func NewGeeterCache(
	data *data.Data,
	logger log.Logger) dao.IGreeterRepo {
	return &geeterCache{
		data: data,
		log:  log.NewHelper(logger),
	}
}

// NewGreeterRepo .
func NewGreeterCache(data *data.Data, logger log.Logger) dao.IGreeterRepo {
	return &geeterCache{
		data: data,
		log:  log.NewHelper(logger),
	}
}

func (r *geeterCache) Save(ctx context.Context, g *dao.Greeter) (*dao.Greeter, error) {
	r.data.Rds.Set(ctx, "hello", g.Hello, 30)
	return g, nil
}

func (r *geeterCache) Update(ctx context.Context, g *dao.Greeter) (*dao.Greeter, error) {
	return g, nil
}

func (r *geeterCache) FindByID(context.Context, int64) (*dao.Greeter, error) {
	return nil, nil
}

func (r *geeterCache) ListByHello(context.Context, string) ([]*dao.Greeter, error) {
	return nil, nil
}

func (r *geeterCache) ListAll(context.Context) ([]*dao.Greeter, error) {
	return nil, nil
}
